package cn.kuang.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author 徽州大都督
 * @date 2020/7/22
 */
@TableName(value = "user")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {

    @TableId("uid")
    private String uid;
    private String username;
    private String password;
    private String email;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date loginTime;  //上次登录时

    private Integer status;
    @TableLogic
    private Integer deleted;
    private Integer loginCount;

    private Integer level;  //等级

    @TableField(exist = false)
    private String ranking;  //称号
    @TableField(exist = false)
    private Integer isSign;  //签到
    @TableField(exist = false)
    private Long total; //分页总条数


    public String getRanking() {

        if (level<100){
            ranking="青铜";
        }else if (level>=100 && level<200){
            ranking="白银";
        }else if (level>=200 && level<300){
            ranking="黄金";
        }else if (level>=300 && level<400){
            ranking="钻石";
        }else{
            ranking="王者";
        }

        return ranking;
    }

    public void setRanking(String ranking) {
        this.ranking = ranking;
    }
}
